package com.vint.mi;

/**
 * 1.done
 * 2.找到前面比它小的数，求和
 *  乱序数组交换成正序，最少次数
 */
public class Mi8 {
    public static String solution(String line){
        String[] src = line.split(",");
        int[] sr = new int[src.length];
        for(int i=0; i<src.length; i++){
            sr[i] = Integer.parseInt(src[i]);
        }
        int sum = 0;
        for(int i=0;i<src.length;i++){
            for(int j=i+1;j<src.length;j++){
            	if(sr[j]<sr[i])sum++;
            }
        }
        return String.valueOf(sum);
    }

    public static void main(String[] args) {
        String ex1 = "1,2,0";
        String ex2 = "3,4,-1,1";
        System.out.println(solution(ex1));
        System.out.println(solution(ex2));
    }
}
